#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>
int  main()
{
    int n, m, i, j;
    int count = 0;
    char arr[50][50];
    scanf("%d%d", &n, &m);
    getchar();
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            scanf("%c", &arr[i][j]);
        }
        getchar();
    }

    for (i = 0; i < n; i++)
    {
        for (j = 0; j < m; j++)
        {
            if (arr[i][j] != 'f' && arr[i][j + 1] != 'f' && arr[i + 1][j] != 'f' && arr[i + 1][j + 1] != 'f')
                continue;
            else if (arr[i][j] != 'a' && arr[i][j + 1] != 'a' && arr[i + 1][j] != 'a' && arr[i + 1][j + 1] != 'a')
                continue;
            else if (arr[i][j] != 'c' && arr[i][j + 1] != 'c' && arr[i + 1][j] != 'c' && arr[i + 1][j + 1] != 'c')
                continue;
            else if (arr[i][j] != 'e' && arr[i][j + 1] != 'e' && arr[i + 1][j] != 'e' && arr[i + 1][j + 1] != 'e')
                continue;
            else
                count++;
        }
    }
    printf("%d", count);
    return 0;
}

